#include <iostream>
#include <cmath>
using namespace std;

int rev(int x)
{
	int tmp = x;
	int digit[7] = { 0 };
	int i = 0;
	int res = 0;
	//计算x的位数
	int digitNum = 1;
	while (tmp != 0)
	{
		digit[i] = tmp % 10;
		tmp = tmp / 10;
		i++;
	}
	digitNum = i;
	//倒序数的值
	for (i = 0; i<digitNum; i++)
	{
		res += digit[i]*pow(10, digitNum - i - 1);
	}
	
	return res;
}

int main()
{
	int n = 0;
	cin >> n;
	int i = 0; 
	for (i = 1; i < n; i++)
	{
		if (i + rev(i) == n)
		{
			cout << i << endl;
		}
	}
	
	return 0;
}
